<?php

 $meta_title = $_REQUEST['meta_tile'];
 $meta_images = $_REQUEST['meta_image'];
 $meta_link = $_REQUEST['meta_link'];
 $meta_description = $_REQUEST['meta_content'];
$post_type = $_REQUEST['post_type'];
$post_image = $_REQUEST['post_image'];
 $post_title = $_REQUEST['post_title'];
$post_datetime = $this->datetime;
$post_content = $_REQUEST['content'];
$ID = $this->postid;
/* // TODO: lay userid tu sestion */
$userid =1;
$username ="le huy truyen";
?>
<div id="new_post" ></div>

<div id="listPost_<?php echo $ID ?>" class="listPost">
	<span class="listpost_span">
					<div class="edit_post">
						<ul>
							<li class="firstItem"></li>
							<li class="lastItem" onclick="return comfirmdelete_popup({id:'<?php echo $ID; ?>',type:'post'})"></li>
						</ul>
					</div>
					<img src="<?php echo $this->baseUrl('public/images/ava.jpg')?>" alt="">
					<h1><a href="" title=""><?php echo $username ?></a> -  <?php echo $post_datetime ?></h1>

	
		<div class="post_show_title"><?php echo $post_title ?></div>
		<div class="post_show_content"><?php echo $post_content ?></div>
					
		
	<?php
					if($post_type==1)
					{
						//Hiển thị link
						
						if($meta_images != "")
						{
							$meta_hinhanh =$meta_images;
						}
						else
						{
							//TODO: thay link hinh khi ko co hinh
							$meta_hinhanh ="";
						}
						$metablock = "block";
						if($meta_title == NUll)
						{
							$metablock = "none";
						}
						?>
						<div class="post_link_comment" style="display:<?php echo $metablock ?>">
									
									<div class="img_link_post_cm">
										<img src="<?php echo $meta_hinhanh?>" />
									</div>
									<div class="noidung_link_post_cm" id="">
										<div class="tittle_link_post_cm">
												<a href="<?php echo $meta_link; ?>" target="_blank">
													<?php echo $meta_title; ?>								
												</a>
										</div>
										<div class="cling_link_post_cm">
											<a href="<?php echo $meta_link; ?>" target="_blank">
												<?php echo $meta_link; ?>			
											</a>
										</div>
										<div class="meta_link_post_cm">
											<?php echo $meta_description; ?>	
										</div>
									</div>
									<div class="clear"></div>
									
						</div>		
					<?php
						$post_images = $post_image;
						if($post_images !="")
						{
							$arr_images = explode(",", $post_images);
							$sl = count($arr_images);
							echo "<div class='post_show_image'>";
							if($sl >= 4){
								foreach($arr_images as $i => $img){
									$url_img = $this->baseUrl('public/images/uploads/'.$img);
									echo "<a class='post_ha_".($i+1)." lb lb_abc' title='abcd' href='$url_img'><img src='$url_img' /></a>";
									if($i==3) break;
								}
							}
							elseif($sl > 1){
								foreach($arr_images as $i => $img){
									$url_img = $this->baseUrl('public/images/uploads/'.$img);
									echo "<a class='post_ha_".($i+2)." lb lb_abc' title='abcd' href='$url_img'><img src='$url_img' /></a>";
								}
							}elseif($sl == 1){
								foreach($arr_images as $i => $img){
									$url_img = $this->baseUrl('public/images/uploads/'.$img);
									echo "<a class='post_ha_".$i." lb lb_abc' title='abcd' href='$url_img'><img src='$url_img' /></a>";
								}
							}
							echo "</div>";
						}
					
					}

					if($post_type==2)
					{
						$post_images = $post_image;
						$arr_images = explode(",", $post_images);
						$sl = count($arr_images);
						echo "<div class='post_show_image'>";
						if($sl >= 4){
							foreach($arr_images as $i => $img){
								$url_img = $this->baseUrl('public/images/uploads/'.$img);
								echo "<a class='post_ha_".($i+1)." lb lb_abc' title='abcd' href='$url_img'><img src='$url_img' /></a>";
								if($i==3) break;
							}
						}
						elseif($sl > 1){
							foreach($arr_images as $i => $img){
								$url_img = $this->baseUrl('public/images/uploads/'.$img);
								echo "<a class='post_ha_".($i+2)." lb lb_abc' title='abcd' href='$url_img'><img src='$url_img' /></a>";
							}
						}elseif($sl == 1){
							foreach($arr_images as $i => $img){
								$url_img = $this->baseUrl('public/images/uploads/'.$img);
								echo "<a class='post_ha_".$i." lb lb_abc' title='abcd' href='$url_img'><img src='$url_img' /></a>";
							}
						}
						echo "</div>";
					
					
					
					
					
					/*
						$post_images = $detai['post_image'];
						$arr_images = explode(",", $post_images);
						$sl = count($arr_images);
						echo "<div class='post_show_image'>";
						if($sl >=4){
							for($i=0; $i<4; $i++){
								echo "<a class='post_ha_".($i+1)." lb lb_abc' title='abcd' href='/hoidap/source/public/images/uploads/h".($i+1).".jpg'><img src='/hoidap/source/public/images/uploads/h".($i+1).".jpg' /></a>";
							}
						}elseif($sl>1){
							for($i=0; $i<$sl; $i++){
								echo "<a class='post_ha_".($i+2)." lb lb_abc' title='abcd' href='/hoidap/source/public/images/uploads/h".($i+2).".jpg'><img src='/hoidap/source/public/images/uploads/h".($i+2).".jpg' /></a>";
							}
						}elseif($sl==1){
							echo "<a class='post_ha_0 lb lb_abc' title='abcd' href='/hoidap/source/public/images/uploads/h1.jpg'><img src='/hoidap/source/public/images/uploads/h1.jpg' /></a>";
						}
						echo "</div>";
						*/
					}
					
					
					if($post_type==3)
					{			
						if($meta_images != "")
						{
							$meta_hinhanh =$meta_images;
						}
						else
						{
							//TODO: thay link hinh khi ko co hinh
							$meta_hinhanh ="";
						}
						$metablock = "block";
						if($meta_title == NUll)
						{
							$metablock = "none";
						}
						?>
						<div class="post_link_comment" style="display:<?php echo $metablock ?>">
									
									<div class="img_link_post_cm">
										<img src="<?php echo $meta_hinhanh?>" />
									</div>
									<div class="noidung_link_post_cm" id="">
										<div class="tittle_link_post_cm">
												<a href="<?php echo $meta_link; ?>" target="_blank">
													<?php echo $meta_title; ?>								
												</a>
										</div>
										<div class="cling_link_post_cm">
											<a href="<?php echo $meta_link; ?>" target="_blank">
												<?php echo $meta_link; ?>			
											</a>
										</div>
										<div class="meta_link_post_cm">
											<?php echo $meta_description; ?>	
										</div>
									</div>
									<div class="clear"></div>
									
						</div>		
						<?php
					}
					?>
	</span>
	<div id="" class="onComment">
		<a href="javascript:none" onclick="document.getElementById('comment_<?php echo  $ID; ?>').style.display='inline-block';document.getElementById('<?php echo  $ID ?>').focus();return false;">Bình luận</a>

		<span id="like_1_<?php echo  $ID ?>" >
			<a href="javascript:none"  onclick="return ajlikes('1','<?php echo $ID?>','<?php echo $userid ?>','','0')" title="">Like</a>
		
		<span id='youlike1<?php echo  $ID; ?>'></span>
		<span id='youlikeand1<?php echo  $ID; ?>'></span>
		<span id='thichdieunay1<?php echo  $ID; ?>'></span>
		
		</span>

		<div id="new<?php echo $ID ?>" ></div>

		<div id="comment_<?php echo $ID ?>" >

		<textarea class="binhluanArea" style="width: 437px; height: 17px;  resize: none;" id="<?php echo $ID?>" onfocus="return add_comment_text({id:'<?php echo  $ID ?>', author:'<?php echo  $userid ?>'})"  placeholder="Viết bình luận..."  autocomplete="off" ></textarea>
</div>
	
	
	</div>
	<div id="" class="clear"></div>
</div>